package com.api.util;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;

import com.liuwang.meal.util.StreamUtils;

import android.content.Context;

public class SendOrder{

	public  String saveOrder(String order) throws Exception {
		
		String path = PublicString.sendOrderUrl;
		 HttpClient client = new DefaultHttpClient();
		HttpPost httpPost = new HttpPost(path);
		List<NameValuePair> parameters = new ArrayList<NameValuePair>();
		parameters.add(new BasicNameValuePair("goodsOrder", order));
		UrlEncodedFormEntity entity = new UrlEncodedFormEntity(parameters,"UTF-8");
		httpPost.setEntity(entity);
		HttpResponse response = client.execute(httpPost);
		int code = response.getStatusLine().getStatusCode();
		System.out.println("发送地址信息得到的返回吗" + code);
	 
		if (code == 200) {
			InputStream is = response.getEntity().getContent();
            String result = StreamUtils.readStream(is);
			System.out.println("发送地址信息得到的结果" + result);
			return result;
		} else {
			return null;
		}
	}

}
